package ru.hh.school.commands;

import ru.hh.school.User;
import ru.hh.school.logging.Logger;

public abstract class AbstractCommand implements Command {
    Logger logger;

    protected AbstractCommand(Logger logger) {
        this.logger = logger;
    }

    public final void handle(User user, String data) {
        this.logCommand(user, data);
        this.process(user, data);
    }

    abstract void process(User user, String data);

    void logCommand(User user, String data) {
        logger.log(user.toString() + ' ' + this.getCommand() + ' ' + data);
    }


}
